<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../Public/css/golbal1.css"/>
<link rel="stylesheet" type="text/css" href="../Public/css/reg1.css"/>
<title>{$_title_}-气象科普网</title>
<js href="__PUBLIC__/Js/Jquery/jquery-1.4.4.min.js" />
<js href="../Public/js/calendar.js" />
<script language="JavaScript">
function showsct(){
	var uname = $("#username").val();
	var uty = $.post("{:U('user/checkuname')}", {username:uname}, function(res){
		if(res){
			$("#usernameinfo").html("您输入的用户名存在");
			return false;
		}else if(uname.length == "")
		{
			$("#usernameinfo").html("用户名不能为空");
			return false;
		}else if(uname.length<6 || uname.length>16)
		{
			$("#usernameinfo").html("用户名由6-16位字符组成");
			return false;
		}
	});
	if($("#usernameinfo").html() != "该用户名可用"){
		return false;
	}
	
	var email = $("#email").val();
	var type = $("#emtype").val();
	$.post("{:U('user/checkemail')}", {email:email,emtype:type}, function(res){
		if(res){
			$("#emailinfo").html("该邮箱已存在");
			return false;
		}else if(email.length==""){
			$("#emailinfo").html("请输入Email");
			return false;
		}
	});
	if($("#emailinfo").html() != "Email通过"){
		return false;
	}
	var pwd = $("#password").val();
	if(pwd.length=="")
	{
		$("#passwordinfo").html("密码不能为空");
	  	return false;
	}else if(pwd.length<6 || pwd.length>16)
	{
		$("#passwordinfo").html("密码由6-16位字符组成");
	  	return false;
	}
	var repwd = $("#repassword").val();
	if(repwd.length=="")
	{
		$("#repasswordinfo").html("密码不能为空");
	  	return false;
	}else if(repwd!=pwd){
		$("#repasswordinfo").html("两次输入不一致");
	  	return false;
	}
	$("#fireg").hide();
	$("#screg").show();
	$("#one").attr("src","../Public/images/one_2.jpg");
	$("#two").attr("src","../Public/images/two_2.jpg");
}
function checkinfo(){
	var nkname = $("#nickname").val();
	if(nkname.length=="")
	{
		$("#nicknameinfo").html("昵称不能为空");
	  	return false;
	}else if(nkname.length<2){
		$("#nicknameinfo").html("昵称长度不能小于2");
	  	return false;
	}else{
		 $('#form1').submit();
	}
}
$(function(){
	$("#username").blur(function() {
		var uname = $(this).val();
		$.post("{:U('user/checkuname')}", {username:uname}, function(res){
			if(res){
				$("#usernameinfo").html("您输入的用户名存在");
				return false;
			}else if(uname.length == "")
			{
				$("#usernameinfo").html("用户名不能为空");
			  	return false;
			}else if(uname.length<6 || uname.length>16)
			{
				$("#usernameinfo").html("用户名由6-16位字符组成");
			  	return false;
			}else
			{
				$("#usernameinfo").html("该用户名可用");
				return true;
			}
		});
	});
	$("#password").blur(function(){
		var pwd = $(this).val();
		if(pwd.length=="")
		{
			$("#passwordinfo").html("密码不能为空");
		  	return false;
		}else if(pwd.length<6 || pwd.length>16)
		{
			$("#passwordinfo").html("密码由6-16位字符组成");
		  	return false;
		}else{
			$("#passwordinfo").html("密码通过");
			return true;
		}
	});
	$("#repassword").blur(function(){
		var repwd = $(this).val();
		var pwd = $("#password").val();
		if(repwd.length=="")
		{
			$("#repasswordinfo").html("密码不能为空");
		  	return false;
		}else if(repwd!=pwd){
			$("#repasswordinfo").html("两次输入不一致");
		  	return false;
		}else{
			$("#repasswordinfo").html("密码通过");
			return true;
		}
	});
	$("#email").blur(function(){
		var email = $(this).val();
		var type = $("#emtype").val();
		$.post("{:U('user/checkemail')}", {email:email,emtype:type}, function(res){
			if(res){
				$("#emailinfo").html("该邮箱已存在");
				return false;
			}else if(email.length==""){
				$("#emailinfo").html("请输入Email");
				return false;
			}else{
				$("#emailinfo").html("Email通过");
				return true;
			}
		});
	});

	$("#emtype").blur(function(){
		var email = $("#email").val();
		var type = $(this).val();
		$.post("{:U('user/checkemail')}", {email:email,emtype:type}, function(res){
			if(res){
				$("#emailinfo").html("该邮箱已存在");
				return false;
			}else if(email.length==""){
				$("#emailinfo").html("请输入Email");
				return false;
			}else{
				$("#emailinfo").html("Email通过");
				return true;
			}
		});
	});
	
	$("#nickname").blur(function(){
		var nkname = $(this).val();
		if(nkname.length=="")
		{
			$("#nicknameinfo").html("昵称不能为空");
		  	return false;
		}else if(nkname.length<2){
			$("#nicknameinfo").html("昵称长度不能小于2");
		  	return false;
		}else{
			$("#nicknameinfo").html("昵称通过");
			return true;
		}
	});
}); 
</script>
</head>

<body>
<div class="reg_w">
<div class="reg_top">
<a href="{:U('Index/index')}"><img src="../Public/images/logo2.jpg" /></a>
<p>已有气象科普资源库账户，请直接<span><a href="{:U('User/login')}">登录</a></span></p>
</div>
<div class="timeline">
<ul>
<li><img id="one" src="../Public/images/one_1.jpg" /><a href="#">填写基本信息</a></li>
<li><img id="two" src="../Public/images/two_1.jpg" /><a href="#">完善账户信息</a></li>
<li><img id="three" src="../Public/images/three_1.jpg" /><a href="#">注册成功</a></li>
</ul>
</div>
<div class="reg_middle">
<div class="regm_l">
<if condition="($tssta eq 1)">
	<div style="padding-top:20px;padding-left:180px;">{$tsinfo}</div>
</if>
<form action="{:U('User/reg')}" method="POST" id="form1" name="form1">
<table id="fireg" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<th height="65">邮件地址：</th>
<td class="mail"><input onkeyup="value=value.replace(/[^a-z0-9_]/g,'')" onpaste="return false" id="email" name="email" type="text"   class="mail_txt"/><span>@</span>
<select id="emtype" name="emtype" style="height:35px; padding: 8px 0;">
<option value="163.com">163.com</option>
<option value="qq.com">qq.com</option>
<option value="126.com">126.com</option>
<option value="126.com">gmail.com</option>
<option value="126.com">googlemail.com</option>
<option value="126.com">yahoo.com</option>
<option value="126.com">sina.com</option>
<option value="126.com">sina.cn</option>
</select></td>
</tr>
<tr><td> &nbsp;</td><td id="emailinfo">可使用字母、数字、下划线</td></tr>
<tr>
<th height="65">用户名：</th>
<td><input id="username" onkeyup="value=value.replace(/[^a-z0-9_]/g,'')" onpaste="return false" name="username" type="text" maxlength="16" /></td>
</tr>
<tr><td> &nbsp;</td><td id="usernameinfo">用户名由6~16个字符组成</td></tr>
<tr>
<th height="65">密码：</th>
<td><input id="password" name="password" type="password" maxlength="16"/></td>
</tr>
<tr><td> &nbsp;</td><td id="passwordinfo">密码由6~16个字符组成</td></tr>
<tr>
<th height="65">确认密码：</th>
<td><input id="repassword" name="repassword" type="password" maxlength="16" /></td>
</tr>
<tr><td> &nbsp;</td><td id="repasswordinfo">请再次填写密码</td></tr>
<tr height="75"><td> &nbsp;</td><td><input type="button" onclick="showsct()"  class="reg_bt"/></td></tr>
</tbody>
</table>

<table id="screg" style="display:none;" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<th height="50">昵称：</th>
<td><input id="nickname" name="nickname" type="text" maxlength="6" /></td>
</tr>
<tr><td> &nbsp;</td><td id="nicknameinfo">2~6个字符，可使用字母、数字、文字</td></tr>
<tr>
<th height="35">性别：</th>
<td><input name="sex" class="rad" checked="checked" type="radio" value="1" /> 男   <input name="sex" class="rad" type="radio" value="2" /> 女</td>
</tr>
<tr>
<th height="50">出生日期：</th>
<td><input id="year" name="year" onkeyup="value=value.replace(/[^\d]/g,'')"
      onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" type="text" maxlength="4" style="width:55px; margin:0 8px;" />年<input id="moth" onkeyup="value=value.replace(/[^\d]/g,'')"
      onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" name="moth" type="text" style="width:25px; margin:0 8px;" maxlength="2" />月<input id="day" onkeyup="value=value.replace(/[^\d]/g,'')"
      onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" name="day" type="text" style="width:25px;margin:0 8px;"  maxlength="2" />日</td>
</tr>
<tr><td> &nbsp;</td><td id="addressinfo">请输入出生日期 例:1975 08 21</td></tr>
<tr>
<th height="80">住址：</th>
<td><textarea name="address" style="width:295px;line-height:25px; height:60px;" onkeyup="limitLength(this,50)"></textarea></td>
</tr>
<tr><td> &nbsp;</td><td id="telinfo">请填写住址，不超过<span>50</span>字</td></tr>
<tr>
<th height="50">手机：</th>
<td><input id="tel" name="tel" type="text" onkeyup="value=value.replace(/[^\d]/g,'')"
      onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" maxlength="11"/></td>
</tr>
<tr><td> &nbsp;</td><td id="telinfo">手机号码由11个数字组成</td></tr>
<tr height="75"><td> &nbsp;</td><td><input type="button" onclick="checkinfo()" class="reg_sub" value="" /></td></tr>
</tbody>
</table>
</form>
</div>
<div class="regm_r">
<img src="../Public/images/regm_rimg.jpg" />
</div>
</div>
<div class="reg_bottom">
<volist id="atlist" name="artlist" key="k">
<a href="{:U('Article/banquan',array('arid'=>$atlist['arid']))}">{$atlist.artitle}</a><if  condition="$artnum neq $k">&nbsp;|&nbsp;</if>
</volist>
<p>版权信息</p>
</div>
</div>
<script language="JavaScript">
		function limitLength(obj, length) {   
	        var desc = obj.value;    
	        obj.value = substr(obj.value,length);   
	    }   
	    function substr(str,length){   
	        var l=0,i=0;   
	        while(l <length && i<str.length){   
	            l+=1;   
	           // if(str.substring(i,i+1).match(/[\u4e00-\u9fa5]/))l+=2;//一个中文是相当于3个英文   
	            i+=1;   
	        }   
	        return str.substring(0,i);   
	    }
</script>
</body>
</html>
